/*
 *    Copyright (c) 2018-2025, infomng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: infomng
 */

import request from "@/router/axios";

export function fetchList(query) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/page",
    method: "get",
    params: query,
  });
}

export function addObj(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain",
    method: "post",
    data: obj,
  });
}

export function addLineObj(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain",
    method: "post",
    data: obj,
  });
}

export function getObj(id) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/" + id,
    method: "get",
  });
}

export function delObj(id) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/" + id,
    method: "delete",
  });
}

export function putObj(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain",
    method: "put",
    data: obj,
  });
}

export function putLineObj(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain",
    method: "put",
    data: obj,
  });
}

/**
 * 新增产线(包含产线配置详情)
 * @param obj
 * @returns {AxiosPromise}
 */
export function saveLine(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/saveLine",
    method: "post",
    data: obj,
  });
}
/**
 * 修改实际产线(包含实际产线配置详情、实际产线设备配置)
 * @param obj
 * @returns {AxiosPromise}
 */
export function updateLine(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/updateLine",
    method: "post",
    data: obj,
  });
}

/**
 * 根据实际产线ID获取实际产线配置数据以及具体详情数据
 * @param id
 * @returns {AxiosPromise}
 */
export function getRealityProductLineDetailsList(id) {
  return request({
    url:
      "/admin-api/o3-pfoc/realityproductlinemain/getRealityProductLineDetailsList/" +
      id,
    method: "get",
  });
}
/**
 * 获取实际产线集合
 * @param id
 * @returns {AxiosPromise}
 */
export function getLineList() {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/getLineList",
    method: "get",
  });
}

/**
 * 根据车间ID获取实际产线集合
 * @param id
 * @returns {AxiosPromise}
 */
export function getLineListByWorkshopId(workshopId) {
  return request({
    url:
      "/admin-api/o3-pfoc/realityproductlinemain/getLineListByWorkshopId/" +
      workshopId,
    method: "get",
  });
}
/**
 *  根据产品ID获取已发布的产线工序
 * @param id
 * @returns {AxiosPromise}
 */
export function getProcessListByLineIdFromRelease(lineId) {
  return request({
    url:
      "/admin-api/o3-pfoc/realityproductlinemain/getProcessListByLineIdFromRelease/" +
      lineId,
    method: "get",
  });
}

/**
 * 新版 -- 新建产线建模(包含产线配置详情)
 * @param obj
 * @returns {AxiosPromise}
 */
export function saveProductLine(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/saveProductLine",
    method: "post",
    data: obj,
  });
}

/**
 * 新版 -- 编辑产线建模(包含产线配置详情)
 * @param obj
 * @returns {AxiosPromise}
 */
export function updateProductLine(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/updateProductLine",
    method: "post",
    data: obj,
  });
}

/**
 * 新版 -- 查询产线详情
 * @param obj
 * @returns {AxiosPromise}
 */
export function getById(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/getById",
    method: "post",
    data: obj,
  });
}

/**
 * 新版 -- 编辑产线设备
 * @param obj
 * @returns {AxiosPromise}
 */
export function updateLineDevice(obj) {
  return request({
    url: "/admin-api/o3-pfoc/realityproductlinemain/updateLineDevice",
    method: "post",
    data: obj,
  });
}
